package com.offcn.controller;

import com.offcn.feign.ProviderFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ConsumerController {

    @Autowired
    private ProviderFeign providerFeign;

    @Value("${test}")
    private String test;

    @GetMapping("hi")
    public String hi() {

       /* try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        //int i=1/0;
        long beginTime = System.currentTimeMillis();
        String hello = providerFeign.hello();
        long endTime=System.currentTimeMillis();
        System.out.printf("系统调用时间:"+(endTime-beginTime));
        return hello;
    }
    //测试hi2
    @RequestMapping("hi2")
    public String hi2(){
        return "hi2:"+test;
    }
}
